<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@include file="/context/mytags.jsp"%>
<div class="col-md-12">
	<div class="panel-search">
	  <form class="form-inline" action="/nurse/list">
		  <div class="form-group">
			  <button type="button" id="statusIdZero" class="btn btn-info" onclick="selectStatus(0,this)">
				  <i class="fa"></i> 全部(<label id="nurseAll"></label>)
			  </button>
			  <button type="button" id="statusIdOne" class="btn btn-info" onclick="selectStatus(1,this)">
				  <i class="fa"></i> 待审核(<label id="nurseWait"></label>)
			  </button>
			  <button type="button" id="statusIdTwo" class="btn btn-info" onclick="selectStatus(2,this)">
				  <i class="fa"></i> 审核通过(<label id="nurseSuccess"></label>)
			  </button>
			  <button type="button" id="statusIdThree" class="btn btn-info" onclick="selectStatus(3,this)">
				  <i class="fa"></i> 审核失败(<label id="nurseFail"></label>)
			  </button>
			  <input type="hidden" name="accountStastus" id="accountStastusId" value="0"/>
			  <%--用于判断到底是后台管理的护士管理还是国内医院的护士管理--%>
			  <input type="hidden" name="pageType" value="departmentNurse">
		  </div>

		  <br/><br/>
		  <div class="form-group">
			  <label class="control-label">科室</label>
			  <input type="text" class="form-control" name="departmentName" placeholder="输入科室查看">
		  </div>
		  <div class="form-group">
			  <label class="control-label">姓名/手机</label>
			  <input type="text" class="form-control" name="nameOrphone" placeholder="输入姓名/手机号">
		  </div>
	  </form>
	  <div class="btn-div">
			<div class="div-left">
				<button type="button" class="btn btn-warning" onclick="add('/nurse/nurse?pageType=departmentNurse')">
				<i class="fa fa-plus"></i> <spring:message code="btn.add"></spring:message>
			</button>
			</div>
			<div class="div-right">
				<button type="button" class="btn btn-primary" onclick="search()">
					<i class="fa fa-search"></i> <spring:message code="btn.search"></spring:message>
				</button>
		    <button type="button" class="btn btn-default" onclick="reset()">
		    	<i class="fa fa-repeat"></i> 刷新
		    </button>
			</div>
		</div>
	</div>
	<div class="panel-content"></div>
	<div class="panel-show"></div>
</div>
<script type="text/javascript" src="<c:url value="/static/custom/datepicker-util.js"></c:url>"></script>
<script type="text/javascript">
	$(function(){
		search();
        queryStatistics();
	});

    /**
	 * 数据统计
     * @param status 状态
     * @param obj 点击的按钮
     */
	function selectStatus(status,obj) {
	    var currentId = obj.id;
	    $("#accountStastusId").val(status);
	    $("button[id^='statusId']").removeClass("btn-success").addClass("btn-info");
        $("#" + currentId).removeClass("btn-info").addClass("btn-success");
        search();
        queryStatistics();
    }

    /**
     * 查询科室的统计信息
     */
    function queryStatistics(){
        $.ajax({
            type: 'post',
            url: '<c:url value="/nurse/queryStatistics"></c:url>',
            data: null,
            dataType: 'json',
            success: function (data) {
                if(!checkResultCode(data.code)){
                    alert(data.message);
                }else {
                    $("#nurseAll").text(data.data.nurseAll);
                    $("#nurseWait").text(data.data.nurseWait);
                    $("#nurseSuccess").text(data.data.nurseSuccess);
                    $("#nurseFail").text(data.data.nurseFail);
                }
            }
        });
    }
</script>